package blogs.eidos.cloud.framework.common.exception;

import net.bigdata.cloud.framework.common.enums.ResultCode;

import java.text.MessageFormat;

/**
 * 系统登录异常
 *
 * @author Eidos
 * @date 2019-08-04
 */
public class UnAuthorizedException extends AbstractCrispsException {

    private Integer code = 5223;
    private String message;

    public UnAuthorizedException() {
        super();
    }

    public UnAuthorizedException(Throwable cause) {
        super(cause);
    }

    public UnAuthorizedException(String message) {
        super(message);
        super.setCode(code);
        this.message = message;
    }


    public UnAuthorizedException(ResultCode resultCode) {
        this.code = resultCode.getCode();
        this.message = resultCode.getMessage();
        super.setCode(code);
        super.setMessage(message);
    }

    public UnAuthorizedException(ResultCode resultCode, Throwable cause) {
        super(resultCode.getCode(), resultCode.getMessage(), cause);
        this.code = resultCode.getCode();
        this.message = resultCode.getMessage();
    }

    public UnAuthorizedException(String message, Throwable cause) {
        super(cause, message);
        super.setCode(code);
        this.message = message;
    }

    public UnAuthorizedException(Integer code, String message) {
        super(code, message);
        this.code = code;
        this.message = message;
    }

    public UnAuthorizedException(Integer code, String message, Throwable cause) {
        super(code, message, cause);
        this.code = code;
        this.message = message;
    }

    public UnAuthorizedException(String pattern, Object... params) {
        super(pattern, params);
        super.setCode(code);
        this.message = MessageFormat.format(pattern, params);
    }

    public UnAuthorizedException(Throwable cause, String pattern, Object... params) {
        super(pattern, params, cause);
        super.setCode(code);
        this.message = MessageFormat.format(pattern, params);
    }
}
